//
//  MessageView.m
//  intelligent
//
//  Created by Ace Portgas on 2024/2/17.
//

#import "MessageView.h"
@interface MessageView()
@property (nonatomic , strong)QInputBarView * putView;
@property (nonatomic , strong)QKeyboardManager * keyBoardManager;

@end
@implementation MessageView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _textField = [[UITextField alloc]init];
        _textField.textColor = [UIColor colorWithHexString:@"#333333"];
        _textField.frame = CGRectMake(13, 12, SCREEN_WIDETH - 48 - 13 - 13 - 8, 40);
        _textField.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
        _textField.placeholder = SQNSLocalString(@"这里输入你的问题...");
        _textField.layer.cornerRadius = 5;
        [self addSubview:_textField];
        
        _textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
        _textField.rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
        _textField.leftViewMode = UITextFieldViewModeAlways;
        _textField.rightViewMode = UITextFieldViewModeAlways;
        
        
        _sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sendBtn setImage:SQGetImage(@"发送-亮") forState:UIControlStateNormal];
        [_sendBtn addTarget:self action:@selector(sendMessage) forControlEvents:UIControlEventTouchUpInside];
        _sendBtn.frame = CGRectMake(SCREEN_WIDETH - 48 - 13, 8, 48, 48);
        [self addSubview:_sendBtn];
    }
    return self;
}

-(void)sendMessage{
    if (self.delegate && [self.delegate respondsToSelector:@selector(sendMessageWithText:)]) {
        [self.delegate sendMessageWithText:_textField.text];
    }
}

@end
